/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package exmtgproj;

import java.awt.Image;
import java.awt.Toolkit;
import java.io.File;
import java.util.ArrayList;

/**
 *
 * @author marcus ahlen
 */
public class Images {

//    static ArrayList<String> savedNames = new ArrayList<String>();
//    static ArrayList<Image> savedImages = new ArrayList<Image>();
    final static Image highlight = getImage("highlight.png");
    final static Image overlay = getImage("overlay.png");
    final static Image back = getImage("back.jpg");
    final static Image noimage = getCard("noimage");
    final static String iconFolder = "icons/";
    final static ArrayList<Image> icons = new ArrayList<Image>();
    final static ArrayList<String> iconNames = new ArrayList<String>();
//    final static Image[] icons = {getImage(iconFolder+"t.gif"),getImage(iconFolder+"q.gif"),getImage(iconFolder+"w.gif"),getImage(iconFolder+"u.gif"),getImage(iconFolder+"b.gif"),getImage(iconFolder+"r.gif"),getImage(iconFolder+"g.gif"),getImage(iconFolder+"1.gif"),getImage(iconFolder+"2.gif"),getImage(iconFolder+"3.gif")};
//    final static String[] iconStr = {"t","q","w","u","b","r","g","1","2","3"};

    public static Image getCard(Card c) {
        String s = "";
        if (c != null) {
            s = c.name;
            if (c.basic) {
                s += (int) (Math.random() * 4 + 1);
            }
        }
        return getCard(s);
    }

    public static Image getCard(String s) {
        File f = new File("cards/" + s + ".full.jpg");
        if (!f.canRead()) {
            s = "noimage";
        }
        Image i;
        System.out.println("lawl");
        i = Toolkit.getDefaultToolkit().createImage("cards/" + s + ".full.jpg").getScaledInstance(MainFrame.edgeLimit, MainFrame.edgeLimit * 17 / 12, Image.SCALE_SMOOTH);
        /*   savedImages.add(i);
        savedNames.add(s);*/
        return i;
    }

    public static Image getImage(String s) {
        Image i = Toolkit.getDefaultToolkit().createImage("images/" + s);
        return i;
    }
    public static Image getIconImage(String s) {
        for(int i = 0; i < iconNames.size(); i++){
            if(s.equalsIgnoreCase(iconNames.get(i))){
                return icons.get(i);
            }
        }
        Image i = getImage("icons/"+s+".gif");
        icons.add(i);
        iconNames.add(s);
        return i;
    }
}
